package Thread;

//引入lambda表达式
//()->{}创建了一个匿名的函数式接口的子类，并且创建出对应的实例，重写方法
public class Demo5 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1=new Thread(() -> {
            while(true){
                System.out.println(Thread.currentThread().getName());
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        t1.start();
        while (true) {
            System.out.println("hello main");
            Thread.sleep(1000);
        }
    }
}
